
function banner(el){
    this.el=$(el);
    this.view=this.el.children('.view')
    this.imgs=this.view.find('img')
    this.dots=this.el.children('.dots');
    this.dot=this.dots.find('li')
    this.btn=this.el.children('.btn')
    this.prev=this.btn.children('.prev')
    this.next=this.btn.children('.next')
    this.cur=0;
    this.timer=null;
    this.init()
}
banner.prototype.init=function(){
    this.imgs.eq(this.cur).css('display', 'block');
    this.dot.eq(this.cur).addClass('active_li')
    this.bindClick()
    this.autoPlay()
    this.switch()
    var _this=this;
    this.el.mouseenter(function() {
        clearInterval(_this.timer)
    });
    this.el.mouseleave(function() {
        _this.autoPlay()
    });
}
banner.prototype.nextPage=function(){
    this.cur++;
    if(this.cur>this.imgs.length-1){
        this.cur=0;
    }
    this.toggle()
}
banner.prototype.prevPage=function(){
    this.cur--
    if(this.cur<0){
        this.cur=this.imgs.length-1
    }
    this.toggle()
}
banner.prototype.toggle=function(){
    this.imgs.eq(this.cur).fadeIn(1000).siblings().fadeOut(1000);
    this.dot.eq(this.cur).addClass('active_li').siblings().removeClass('active_li')
}
banner.prototype.bindClick=function(){
    var _this=this;
    this.next.click(function(){
        _this.nextPage()
    })
    this.prev.click(function(){
        _this.prevPage()
    })
}
banner.prototype.autoPlay=function(){
    var _this=this;
    this.timer=setInterval(function(){
        _this.nextPage()
    },3000)
}
banner.prototype.switch=function(){
    var _this=this;
    this.dot.mouseenter(function(){
        _this.cur=$(this).index();
       console.log(_this.cur)
       _this.toggle()
    })
}